﻿using Microsoft.SqlServer.Dts.Pipeline.Wrapper;

namespace NazTek.Documenter.Ssis.Control.Tasks.PipeSubComponent
{
    internal abstract class Base : IBasicComponent
    {
        public string Name { get { return Metadata.Name; } }
        public string Description { get { return Metadata.Description; } }
        public string Documentation
        {
            get
            {
                return string.Format("<li>{0} [{1}]<br>{2}</li>", 
                    Name, Description, GetOperation(Parent).Documentation);
            }
        }

        protected SsisPipe Parent { get; private set; }
        protected IDTSComponentMetaData100 Metadata { get; private set; }
        protected Base(IDTSComponentMetaData100 subComponent, SsisPipe parent)
        {
            Parent = parent;
            Metadata = subComponent;
        }
        protected abstract Operation GetOperation(SsisPipe parent);
        protected static string GetTableName(IDTSComponentMetaData100 component)
        {
            return Utility.GetCustomPropertyValue(component, "OpenRowset");
        }
    }
}